package guitu;

import java.util.Random;

public class cc extends Thread {
	String name;
	int i;

	Tortoise(String name) {
		this.name = name;
		i = 0;

	}

	public void run() {
		while (true) {
			Random r = new Random();
			int x = (r.nextInt() % 2) + 1;
			System.out.println(name + "休息" + x + "秒");

			try {
				sleep(x * 1000);
			} catch (InterruptedException e) {

				e.printStackTrace();
			}

			System.out.println(name + "跑了" + (i = i + 2));
			if (i >= 20) {
				System.out.println(name + "跑过了终点");
				return;
			}
		}

	}
}